import React, { useState, createContext } from 'react';
import Contextson1 from './ContextSon1'

// 创建上下文， 是一个组件,将数据传给每一个子组件
export const MyContext = createContext()
const Contextfather = () => {
  const [name, setName] = useState('邪恶小法师');
  return (
    <div>
      <p>父组件-{name}</p>
      <MyContext.Provider value={name}>
        <Contextson1></Contextson1>
      </MyContext.Provider>
    </div>
  );
}

export default Contextfather;
